package com.example.event;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    TextView txt2;
    @BindView(R.id.txt)
    TextView txt;
    @BindView(R.id.button_6)
    Button button6;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);


        final TextView txt1 = (TextView) findViewById(R.id.txt);
        txt2 = (TextView) findViewById(R.id.txt);
        Button bn1 = (Button) findViewById(R.id.button_1);
        bn1.setOnClickListener(this);

        Button bn2 = (Button) findViewById(R.id.button_2);
        bn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                txt1.setText("点击了采用匿名内部类的监听器");
            }
        });
        Button bn4 = (Button) findViewById(R.id.button_4);
        bn4.setOnClickListener(new MyClickListener());
        Button bn5 = (Button) findViewById(R.id.button_5);
        bn5.setOnClickListener(new myOnClickListener(txt1) {
            @Override
            public void onClick(View v) {
                super.onClick(v);
            }
        });
        Button bn7 = (Button)findViewById(R.id.button_7);
        bn7.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,ConfigurationTest.class);
                startActivity(intent);
            }
        });

        Button bn8 = (Button)findViewById(R.id.button_8);
        bn8.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,ProgressDialogTest.class);
                startActivity(intent);
            }
        });

    }
    @OnClick(R.id.button_6)
    public void onViewClicked(){
        txt.setText("点击了采用ButterKnife的监听器");
    }

    public void clickHandler(View source) {
        TextView txt3 = (TextView) findViewById(R.id.txt);
        txt3.setText("点击了采用绑定到标签的监听器");
    }

    @Override
    public void onClick(View v) {
        txt2.setText("点击了采用Activity作为的监听器");
    }

    class MyClickListener implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            TextView txt = (TextView) findViewById(R.id.txt);
            txt.setText("点击了采用内部类的监听器");
        }
    }

}




